package Demo_02;

import java.sql.*;

public class DemoOld {
    public static void main(String[] args) {
        String driver = "com.mysql.cj.jdbc.Driver";
        String url = "jdbc:mysql://localhost:3306/jdbc? " +
                "serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false";
        String user = "root";
        String password = "root123";
        Connection conn = null;
        PreparedStatement pstm = null;
        ResultSet rst = null;
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } finally {

        }

        try {

            conn = DriverManager.getConnection(url,user,password);
            String sql = "update student set sname=? , ssex = ?"+
                    " where sid=?";
            pstm = conn.prepareStatement(sql);
            pstm.setString(1,"mayue");
            pstm.setString(2,"nv");
            pstm.setString(3,"6");
            int r = pstm.executeUpdate();
            System.out.println(r);

        } catch (SQLException e) {

            e.printStackTrace();
        } finally {
            if (rst!=null){
                try {
                    rst.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                } finally {
                    rst=null;
                }
            }


        }
    }
}
